package com.jikangjun.disk.spring.security;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class SecurityUtils {
    public static UserDiskEntity getCurrentUser() {
        // 实现逻辑：从SecurityContext中获取当前登录用户
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if (authentication != null && authentication.getPrincipal() instanceof UserDiskEntity) {
            return (UserDiskEntity) authentication.getPrincipal();
        }
        return null; // 或抛出未登录异常
    }
}
